#
# Copyright (c) 2021 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#
cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(bt_mesh_ligth_ctrl_sybsystem_test)

FILE(GLOB app_sources src/*.c)

target_sources(app
  PRIVATE
  ${app_sources}
  ${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh/light_ctrl_srv.c
  ${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh/light_ctrl_reg.c
  ${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh/light_ctrl_reg_spec.c
  ${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh/sensor_types.c
  ${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh/sensor.c
  )

target_include_directories(app
  PRIVATE
  ${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh
  ${ZEPHYR_BASE}/subsys/bluetooth
  )

target_compile_options(app
  PRIVATE
  -DCONFIG_BT_MESH_MODEL_KEY_COUNT=5
  -DCONFIG_BT_MESH_MODEL_GROUP_COUNT=5
  -DCONFIG_BT_LOG_LEVEL=0
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV=1
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_RESUME_DELAY=0
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_MANUAL=5
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_OCCUPANCY_MODE=1
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_OCCUPANCY_DELAY=0
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_ON=1000
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_ON=60
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_PROLONG=5000
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_STANDBY_AUTO=5000
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_PROLONG=3
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_TIME_FADE_STANDBY_MANUAL=700
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_STANDBY=700
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_ON=20000
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_LVL_PROLONG=10000
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_REG=1
  -DCONFIG_BT_MESH_LIGHT_CTRL_REG=1
  -DCONFIG_BT_MESH_LIGHT_CTRL_REG_SPEC=1
  -DCONFIG_BT_MESH_LIGHT_CTRL_REG_SPEC_INTERVAL=100
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_KIU=250
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_KID=25
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_KPU=80
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_KPD=80
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_ACCURACY=2
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_LUX_ON=500
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_LUX_PROLONG=200
  -DCONFIG_BT_MESH_LIGHT_CTRL_SRV_REG_LUX_STANDBY=100
  -DCONFIG_BT_MESH_LIGHT_CTRL_AMB_LIGHT_LEVEL_TIMEOUT=20
  -DCONFIG_BT_MESH_SENSOR_USE_LEGACY_SENSOR_VALUE=1
  -DCONFIG_BT_MESH_SENSOR_CHANNELS_MAX=1
  -DCONFIG_BT_MESH_USES_TINYCRYPT
)

zephyr_linker_sources(SECTIONS ${ZEPHYR_NRF_MODULE_DIR}/subsys/bluetooth/mesh/sensor_types.ld)

zephyr_ld_options(
    ${LINKERFLAGPREFIX},--allow-multiple-definition
    )
